package ModelLayer;

 



import static org.junit.Assert.*;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

/**
 * The test class DvdConTest.
 *
 * @author  (your name)        personCo1.clearPersons();
 * @version (a version number or a date)
 */
public class DvdConTest
{
    private ModelLayer.DvdCon dvdCon1;
    /**
     * Default constructor for test class DvdConTest
     */
    public DvdConTest()
    {
    }

    /**
     * Sets up the test fixture.
     *
     * Called before every test case method.
     */
    @Before
    public void setUp()
    {
        dvdCon1 = ModelLayer.DvdCon.getInstance();
    }

    /**
     * Tears down the test fixture.
     *
     * Called after every test case method.
     */
    @After
    public void tearDown()
    {
        dvdCon1.clearDvds();
    }
    
    @Test
    public void addDvd()
    {
        ModelLayer.Dvd dvd1 = new ModelLayer.Dvd("ABAB", "Die Hard", "Madonna", "1980");
        dvdCon1.addDvd(dvd1);
        assertEquals(1, dvdCon1.getDvdsSize());        
    }

    @Test
    public void deleteDvd()
    {
        ModelLayer.Dvd dvd1 = new ModelLayer.Dvd("ABAB", "Die Hard", "Madonna", "1980");
        dvdCon1.addDvd(dvd1);
        assertEquals(1, dvdCon1.getDvdsSize());
        dvdCon1.deleteDvd(dvd1);
        assertEquals(0, dvdCon1.getDvdsSize());
    }

    @Test
    public void findDvd()
    {
        ModelLayer.Dvd dvd1 = new ModelLayer.Dvd("ABAB", "Die Hard", "Madonna", "1980");
        ModelLayer.Dvd dvd2 = new ModelLayer.Dvd("DBDB", "Harry Potter 4", "Elton John", "1999");
        dvdCon1.addDvd(dvd1);
        dvdCon1.addDvd(dvd2);
        ModelLayer.Dvd dvd3 = dvdCon1.findDvd("Harry Potter 4");
        assertEquals(dvd2, dvd3);
    }
    
    @Test
    public void findDvdNotThere()
    {
        ModelLayer.Dvd dvd1 = new ModelLayer.Dvd("ABAB", "Die Hard", "Madonna", "1980");
        ModelLayer.Dvd dvd2 = new ModelLayer.Dvd("DBDB", "Harry Potter 4", "Elton John", "1999");
        dvdCon1.addDvd(dvd1);
        dvdCon1.addDvd(dvd2);
        assertEquals(null, dvdCon1.findDvd("Teletubbies Adventure"));        
    }
}


